import java.util.Scanner;

public class Main {
    public int getLCA(int a, int b) {
        if (a == b) return a;
        int parentA = a / 2;
        int parentB = b / 2;
        while (parentA != parentB) {
            if (parentA > parentB) {
                parentA /= 2;
            } else {
                parentB /= 2;
            }
        }
        return parentA;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int ret = 0;
        int count = 0;
        for (int i = 0; i < 32; i++) {
            if (((n >> i) & 1) == 1) {
                count++;
            } else {
                ret = Math.max(ret, count);
                count = 0;
            }
        }
        System.out.println(ret);
    }
}

// 00000000 00000000 00000000 00000011
// 00000000000000000000000000000000001